package com.x9space.web.business.test.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.x9space.common.annotation.Log;
import com.x9space.common.core.controller.BaseController;
import com.x9space.common.core.domain.AjaxResult;
import com.x9space.common.enums.BusinessType;
import com.x9space.business.test.domain.X9sTest;
import com.x9space.business.test.service.IX9sTestService;
import com.x9space.common.utils.poi.ExcelUtil;
import com.x9space.common.core.page.TableDataInfo;

/**
 * 测试Controller
 * 
 * @author x9space
 * @date 2021-07-09
 */
@RestController
@RequestMapping("/business/test")
public class X9sTestController extends BaseController
{
    @Autowired
    private IX9sTestService x9sTestService;

    /**
     * 查询测试列表
     */
    @PreAuthorize("@ss.hasPermi('business:test:list')")
    @GetMapping("/list")
    public TableDataInfo list(X9sTest x9sTest)
    {
        startPage();
        List<X9sTest> list = x9sTestService.selectX9sTestList(x9sTest);
        return getDataTable(list);
    }

    /**
     * 导出测试列表
     */
    @PreAuthorize("@ss.hasPermi('business:test:export')")
    @Log(title = "测试", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(X9sTest x9sTest)
    {
        List<X9sTest> list = x9sTestService.selectX9sTestList(x9sTest);
        ExcelUtil<X9sTest> util = new ExcelUtil<X9sTest>(X9sTest.class);
        return util.exportExcel(list, "test");
    }

    /**
     * 获取测试详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:test:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(x9sTestService.selectX9sTestById(id));
    }

    /**
     * 新增测试
     */
    @PreAuthorize("@ss.hasPermi('business:test:add')")
    @Log(title = "测试", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody X9sTest x9sTest)
    {
        return toAjax(x9sTestService.insertX9sTest(x9sTest));
    }

    /**
     * 修改测试
     */
    @PreAuthorize("@ss.hasPermi('business:test:edit')")
    @Log(title = "测试", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody X9sTest x9sTest)
    {
        return toAjax(x9sTestService.updateX9sTest(x9sTest));
    }

    /**
     * 删除测试
     */
    @PreAuthorize("@ss.hasPermi('business:test:remove')")
    @Log(title = "测试", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(x9sTestService.deleteX9sTestByIds(ids));
    }
}
